package com.li.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;

import com.ndboo.reslibrary.R;

/**
 * Author: Li
 * Date: 2017/8/8
 * Description:
 */

public class ImgTxtTxt extends FrameLayout {
    private ImageView mImgIcon;
    private TextView mTxtTitle;
    private TextView mTxtNote;
    public ImgTxtTxt(@NonNull Context context) {
        super(context);
    }

    public ImgTxtTxt(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        View view= LayoutInflater.from(context)
                .inflate(R.layout.layout_img_txt_txt,this);
        mImgIcon= (ImageView) view.findViewById(R.id.img_icon);
        mTxtTitle= (TextView) view.findViewById(R.id.txt_title);
        mTxtNote= (TextView) view.findViewById(R.id.txt_note);


        TypedArray array=context.obtainStyledAttributes(attrs,R.styleable.ImgTxtTxt);

        int img=array.getResourceId(R.styleable.ImgTxtTxt_img,-1);
        String txtTitle=array.getString(R.styleable.ImgTxtTxt_txtTitle);
        String txtNote=array.getString(R.styleable.ImgTxtTxt_txtNote);

        array.recycle();

        mImgIcon.setImageResource(img);
        mTxtTitle.setText(txtTitle);
        mTxtNote.setText(txtNote);

    }
}
